import React from 'react';
import dva from 'dva';
import {Router, Route, Switch} from 'dva/router';
import dynamic from 'dva/dynamic';

// import HomePage from './pages/HomePage';
// import CategoryPage from './pages/CategoryPage';

const RouterConfig = ({history}) => {
    console.log('路由...', history,)
    const app = dva();
    const HomePage = dynamic({
        app,
        models: () => [
            import('./models/home'),
        ],
        component: () => import('./pages/HomePage'),
    });
    const CategoryPage = dynamic({
        app,
        models: () => [
            import('./models/category'),
        ],
        component: () => import('./pages/CategoryPage'),
    });
    return (
        <Router history={history}>
            <Switch>
                <Route path="/" exact component={HomePage}/>
                <Route path="/category" exact component={CategoryPage}/>
            </Switch>
        </Router>
    );
};

export default RouterConfig;
